package com.wjbgn.stater.handler;

import com.wjbgn.stater.dto.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * description: 全局异常捕获
 *
 * @author: weirx
 * @time: 2021/3/24 10:03
 */
@Slf4j
@ControllerAdvice
public class GlobalExceptionHandler {

    @ResponseBody
    @ExceptionHandler(value = Exception.class)
    public Result errorHandler(Exception e) {
        log.error("[GlobalExceptionHandler]捕获全局异常，msg = {}", e);
        return Result.failed("系统异常，请查看日志");
    }
}